[bits 32]
   
; void task_switch((uint32_t old_task, uint32_t new_task)

extern sched
extern active_task_esp


;  PUSHA
;  save the ESP
;  get a new ID
;  restore the ESP
;  POPA

global GUTS
GUTS:
    pusha
    
    mov eax, dword [active_task_esp]    ; get the &task[active_id].stack
    mov dword [eax], esp                ; task[active_id].stack = esp
    
    call sched
    
    mov eax, dword [active_task_esp]    ; get the &task[active_id].stack
    mov esp, dword [eax]                ; esp = task[active_id].stack
    
    popa
    
    ret

